package com.atguigu.day13.teacher.in4;

import org.junit.Test;

public class FlyTest {

    @Test
    public void test01(){
        SuperMan man = new SuperMan();
        showFly(man);
    }
    @Test
    public void test02(){
        //多态向上转型
        Fly f = new Fly() {
            @Override
            public void flying() {
                System.out.println("飞机 轰隆隆飞.....");
            }
        };
        showFly(f);
    }

    @Test
    public void test03(){
     //todo 直接将匿名子类对象作为参数传递
        showFly(new Fly() {
            @Override
            public void flying() {
                System.out.println("小蜜蜂 飞飞飞....");
            }
        });
    }
    @Test
    public void test04(){
     //showFly(()-> System.out.println("蝙蝠会飞....."));
    }

    public void showFly(Fly f){
        f.flying();
    }
}
class SuperMan implements Fly{
    @Override
    public void flying() {
        System.out.println("超人 嗖一下 飞");
    }
}